/**
 * 交互反馈
 * https://uniapp.dcloud.io/api/ui/prompt.html
 */

/**
 * 显示消息提示框
 * @param title
 * @param options
 * @constructor
 */
export function showToast(title : string, options ?: Partial<UniApp.ShowToastOptions>) {
	uni.showToast({
		title,
		duration: 1500,
		icon: 'none',
		mask: true,
		...options,
	});
}

/**
 * 显示确认框
 * @param title
 * @param options
 * @constructor
 */
export function showConfirm(title : string, options ?: Partial<UniApp.ShowModalOptions>) {
	return new Promise((resolve, reject) => {
		uni.showModal({
			title,
			...options,
			success: function (res) {
				if (res.confirm) {
					console.log('用户点击确定');
					resolve(true);
				} else if (res.cancel) {
					console.log('用户点击取消');
					reject();
				}
			},
		});
	});
}

/**
 * 加载中
 */
export function showLoading(title : string, options ?: Partial<UniApp.ShowLoadingOptions>) {
	uni.showLoading({
		title,
		...options
	})
}